import requests
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
}

url = 'https://image.baidu.com/search/acjson'

# ctrl + r 匹配工具
params = {
    'tn': 'resultjson_com',
    'logid': '7161243230886579144',
    'ipn': 'rj',
    'ct': '201326592',
    'is': '',
    'fp': 'result',
    'fr': 'ala',
    'word': '美女',
    'cg': 'girl',
    'queryWord': '美女',
    'cl': '2',
    'lm': '-1',
    'ie': 'utf-8',
    'oe': 'utf-8',
    'adpicid': '',
    'st': '',
    'z': '',
    'ic': '',
    'hd': '',
    'latest': '',
    'copyright': '',
    's': '',
    'se': '',
    'tab': '',
    'width': '',
    'height': '',
    'face': '',
    'istype': '',
    'qc': '',
    'nc': '',
    'expermode': '',
    'nojc': '',
    'isAsync': '',
    'pn': '90',
    'rn': '30',
    'gsm': '5a',
    1659266136010: ''
}

response = requests.get(url=url, params=params, headers=headers)
json_data = response.json()
list_data = json_data['data']
for data in list_data:
    try:
        img_url = data['middleURL']
    except Exception as e:
        print('没有找到图片地址')
    else:
        print(img_url)
